#include "Protocol.h"
#include <iostream>

using namespace std;

int main() {
    Protocol protocol;
    const char buf[6] = "12345";
    protocol.setData("12345", 5);
    uint8_t bcc = 0;
    for(int i = 0; i < 5; ++i) {
        bcc ^= buf[i];
    }
    auto checkData = protocol.getData();
    if(checkData.size() != 9) {
        return -1;
    }
    // 单元测试
    cout << "check head_0: " << std::boolalpha << (checkData[0] == 'S') << std::endl;
    cout << "check head_1: " << std::boolalpha << (checkData[1] == 'C') << std::endl;
    cout << "check length: " << std::boolalpha << (checkData[2] == 5) << std::endl;
    cout << "check data_0: " << std::boolalpha << (checkData[3] == '1') << std::endl;
    cout << "check data_1: " << std::boolalpha << (checkData[4] == '2') << std::endl;
    cout << "check data_2: " << std::boolalpha << (checkData[5] == '3') << std::endl;
    cout << "check data_3: " << std::boolalpha << (checkData[6] == '4') << std::endl;
    cout << "check data_4: " << std::boolalpha << (checkData[7] == '5') << std::endl;
    cout << "check bcc: " << std::boolalpha << (checkData[8] == bcc) << std::endl;
    return 0;
}